<template>
    <div class="detail-action">
      <div class="state">
        <span class="iconfont" :class="[`icon-order-${orderStatus[order.orderState].name}`]"></span>
        <p>{{orderStatus[order.orderState].label}}</p>
      </div>
      <div class="info">
        <p>订单编号：{{order.id}}</p>
        <p>下单时间：{{order.createTime}}</p>
      </div>
      <div class="btn">
        <!-- 待付款 -->
        <template v-if="order.orderState === 1">
            <TiziButton @click="$router.push(`/member/pay?orderId=${order.id}`)" type="primary" size="small">立即付款</TiziButton>
            <TiziButton @click="handlerCancel(order)" type="plain" size="small">取消订单</TiziButton>
        </template>
        <!-- 待发货 -->
        <template v-if="order.orderState === 2">
            <TiziButton @click="$router.push(`/member/checkout?orderId=${order.id}`)" type="primary" size="small">再次购买</TiziButton>
        </template>
        <!-- 待收货 -->
        <template v-if="order.orderState === 3">
            <TiziButton @click="handlerConfirm(order)" type="primary" size="small">确认收货</TiziButton>
            <TiziButton @click="$router.push(`/member/checkout?orderId=${order.id}`)" type="plain" size="small">再次购买</TiziButton>
        </template>
        <!-- 待评价 -->
        <template v-if="order.orderState === 4">
            <TiziButton @click="$router.push(`/member/checkout?orderId=${order.id}`)" type="primary" size="small">再次购买</TiziButton>
            <!-- <TiziButton type="plain" size="small">评价商品</TiziButton>
            <TiziButton type="gray" size="small">申请售后</TiziButton> -->
        </template>
        <!-- 已完成 -->
        <template v-if="order.orderState === 5">
            <TiziButton @click="$router.push(`/member/checkout?orderId=${order.id}`)" type="primary" size="small">再次购买</TiziButton>
            <!-- <TiziButton type="plain" size="small">查看评价</TiziButton>
            <TiziButton type="gray" size="small">申请售后</TiziButton> -->
        </template>
      </div>
      <OrderCancel ref="orderCancelCom" />
    </div>
</template>
<script>
import {orderStatus} from '@/api/constants'
import OrderCancel from './order-cancel.vue'
import { useCancel, useConfirm } from '../index.vue'
export default {
  name: 'OrderDetailAction',
  components:{ OrderCancel},
  props: {
    order: {
        type:Object,
        default:()=> ({})
    }
  },
  setup (props) {
    return {orderStatus,...useCancel(),...useConfirm()}
  }
}
</script>
<style scoped lang="less">
.detail-action {
  height: 180px;
  width: 100%;
  display: flex;
  align-items: center;
  .state {
    width: 220px;
    text-align: center;
    .iconfont {
      font-size: 40px;
      color: @tiziColor;
    }
    p {
      font-size: 16px;
      color: #666;
      margin-bottom: 10px;
    }
  }
  .info {
    width: 240px;
    line-height: 30px;
    p {
      color: #999;
    }
  }
  .btn {
    flex: 1;
    text-align: right;
    margin-right: 100px;
    .tizi-button {
      margin-left: 20px;
    }
  }
}
</style>